package com.deluxelx.soul.inn.common.util;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

/**
 * 对象工具类
 *
 * @author: zihao.liao
 * @date: 2024/5/28 22:46
 */
public class ObjectUtil {

    public static <T extends Cloneable> List<T> deepCopyList(List<T> originalList, Function<T, T> cloneFunction) {
        if (originalList == null || originalList.isEmpty()) {
            return null;
        }
        List<T> clonedList = new ArrayList<>();
        for (T item : originalList) {
            T clonedObject = cloneFunction.apply(item);
            clonedList.add(clonedObject);
        }
        return clonedList;
    }

}
